# # 119 复写父类的成员和调用父类成员
# class Phone:
#     IMEI = None
#     producer = 'ITCAST'
#
#     def call_by_5g(self):
#         print('使用5G网络进行通话')
#
#
# # 定义子类，复写父类成员
# class MyPhone(Phone):
#     producer = "ITHEIMA"
#
#     def call_by_5g(self):
#         print("开启单核CPU模式，确保通话的时候省电")
#         # 方式1
#         # print(f"父类的厂商是：{Phone.producer}")
#         # Phone.call_by_5g(self)
#         # 方式2
#         print(f"父类的厂商是：{super().producer}")
#         super().call_by_5g()
#         print("关闭CPU单核模式，确保性能")
#
#
# phone = MyPhone()
# phone.call_by_5g()
# print(phone.producer)

# 120 变量的类型注解
# # 基础数据类型注解
# import json
# import random
#
# # var_1: int = 10
# # var_2: str = "itheima"
# # var_3: bool = True
# # 类对象类型注解
# class Student:
#     pass
# stu: Student = Student()
#
# # 基础容器类型注解
# # my_list: list = [1, 2, 3]
# # my_tuple: tuple = (1, 2, 3)
# # my_dict: dict = {"itheima": 666}
# # 容器类型详细注解
# my_list: list[int] = [1, 2, 3]
# my_tuple: tuple[int, str, bool] = (1, "itheima", True)
# my_dict: dict[str, int] = {"itheima": 666}
# # 在注释中进行类型注解
# var_1 = random.randint(1, 10)   # type: int
# var_2 = json.loads('{"name": "zhangsan"}')  # type: dict[str, str]
# def func():
#     return 10
# var_3 = func()  # type: int
# # 类型注解的限制
# var_4: int = "itheima"
# var_5: str = 123

# 121 函数和方法类型注解
# 对形参进行类型注解
# def add(x: int, y: int):
#     return x + y
#
#
# # 对返回值进行类型注解
# def func(data: list) -> list:
#     return data
#
#
# print(func(1))
# print(f"{type(func(1))}")

# 122 Union联合类型注解
# from typing import Union
#
# my_list: list[Union[int, str]] = [1, 2, "wenxiaojian", 'hanlei']
#
#
# def func(data: Union[int, str]) -> Union[int, str]:
#     pass

# 123 多态
# class Animal:
#     def speak(self):
#         pass
#
#
# class Dog(Animal):
#     def speak(self):
#         print("汪汪汪")
#
#
# class Cat(Animal):
#     def speak(self):
#         print("喵喵喵")
#
#
# def make_noise(animal):
#     animal.speak()
#
#
# dog = Dog()
# cat = Cat()
#
# make_noise(dog)
# make_noise(cat)

# 演示抽象类
# class AC:
#     def cool_wind(self):
#         """制冷"""
#         pass
#
#     def hot_wind(self):
#         """制热"""
#         pass
#
#     def swing_l_r(self):
#         """左右摆风"""
#         pass
#
#
# class Midea_AC(AC):
#     def cool_wind(self):
#         print("美的空调制冷")
#
#     def hot_wind(self):
#         print("美的空调制热")
#
#     def swing_l_r(self):
#         print("美的空调左右摆风")
#
#
# class GREE_AC(AC):
#     def cool_wind(self):
#         print("格力空调制冷")
#
#     def hot_wind(self):
#         print("格力空调制热")
#
#     def swing_l_r(self):
#         print("格力空调左右摆风")
#
#
# def make_cool(ac: AC):
#     ac.cool_wind()
#
#
# midea_ac = Midea_AC()
# gree_ac = GREE_AC()
#
# make_cool(midea_ac)
# make_cool(gree_ac)
